# encoding: UTF-8
 
class Admin::NewtosController < ApplicationController
  
  before_filter :user_signed_in?
  
  def index
    @newtos = Newto.all
    set_seo_meta '新手指引'
  end

  def new
    set_seo_meta '增加新手指引'
  end
  
  def create
    @newto = Newto.new(params[:session])
    if @newto.save!
      redirect_to newtos_path, notice: '新增成功!'
    else
      redirect_referrer_or_default default
    end  
  end

  def edit
    @newto = Newto.find(params[:id]) 
    set_seo_meta '内容修改'
  end

  def update
    @newto = Newto.find(params[:id])
    if @newto.update_attributes!(params[:session])
      redirect_to newtos_path, notice:'修改成功'
    else
      redirect_referrer_or_defautl default
    end
  end

  def destroy
    if Newto.delete(params[:id])
      redirect_to newtos_path, notice:'删除成功'
    else
      redirect_referrer_or_default default
    end  
  end

end
